﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MutFormStudio {
	public class ClosingControlFlag {
		/// <summary> 即将关闭的控件对应的StudioFormHead </summary>
		internal readonly StudioFormHead head;
		bool cancle_closing = false;
		private Action<Control> _dControlClosed = (c) => { c.Dispose(); };


		/// <summary> 此控件将被关闭 </summary>
		public Control Control  => head.control;

		/// <summary>是否取消关闭事件</summary>
		public bool Cancle { get => cancle_closing; set => cancle_closing = value; }

		/// <summary>窗体执行完关闭事件后，销毁控件的程序，如果控件在别处还要使用，也可以替换此函数，从而用在他处。 </summary>
		public Action<Control> dControlClosed { get => _dControlClosed; set => _dControlClosed = value; }
		internal ClosingControlFlag(StudioFormHead head_to_close) {
			this.head = head_to_close;
		}
	}
	public enum StudioCloseReason {
		Close_one,
		Close_independent_form,
	}

	public class ControlsCloseEventArgs : EventArgs {

		/// <summary>表示关闭多个控件的原因。</summary>
		public StudioCloseReason Reason;

		/// <summary>保存每一个即将关闭的控件。其中的Cancle表示是否取消关闭某一个控件。</summary>
		public ClosingControlFlag[] Close_flags { get; set; }
		/// <summary>表示是否阻止关闭全部控件。</summary>
		public bool Cancle_all { get; set; } = false;
		public ControlsCloseEventArgs() {
			
		}
	}

}
